There are many applications where precise control of the position of a beam's focal point with respect to a surface is required. For example, optical inspection, machine vision, laser patterning, and a variety of other similar applications require dynamic control of a focal length by closing a position control loop on a measured distance to a substrate surface (or surfaces). In some instances, the form factor of the substrate dictates that the measurement of a distance between a lens and a surface of a substrate be performed from the same side of the substrate as the patterning laser, inspection optics, etc. Further, in some instances, the substrate surface may be uneven over short distances which may result in error in the distance measurement as the measurement position deviates from the position of interest. For this reason, the measurement of a distance to a surface may be performed at a point close to a position to be patterned or inspected.